package fons.navigator.ui.actions;

import java.awt.Dimension;
import java.awt.event.ActionEvent;

import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;

import edu.umd.cs.piccolo.PCanvas;
import fons.navigator.ui.NavigatorMainFrame;
import fons.navigator.ui.browsers.dimensions.DimensionBrowserCanvas;
import fons.navigator.util.piccolo.PanHandler;
import fons.navigator.util.piccolo.ZoomHandler;

@ActionDescription(
		menu = "Ontologie",
		name = "Dimensions-Browser",
		description = "Dimensionen anzeigen und durchsuchen",
		priority = 1
)
public class DimensionBrowserAction extends NavigatorAbstractAction {	
	private static final long serialVersionUID = 1L;
	
	public DimensionBrowserAction (NavigatorMainFrame app) {
		super(app, false);
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		final JDesktopPane desktopPane = getApp().getDesktopPane();
		final JInternalFrame frame = new JInternalFrame("Dimensionen", true, true, true, true);
		frame.setPreferredSize(new Dimension(600, 600));
		desktopPane.add(frame);
		
		PCanvas canvas = new DimensionBrowserCanvas(getApp().getActiveContext());
		
		canvas.setZoomEventHandler(null);
		canvas.setPanEventHandler(null);
		canvas.addInputEventListener(new ZoomHandler());
		canvas.setPanEventHandler(new PanHandler(false));
		
		frame.add(canvas);
		
		frame.pack();
		frame.setVisible(true);
	}
}
